package com.atguigu.servicesta.controller;


import com.atguigu.commonutils.R;
import com.atguigu.servicesta.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author JY
 * @since 2021-02-07
 */
@RestController
@RequestMapping("/servicesta/sta")
@CrossOrigin
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService dailyService;

    //新增
    @PostMapping("add/{day}")
    public R createStatisticsByDate(@PathVariable String day){
        dailyService.createStatisticsByDate(day);
        return R.ok();
    }

    //根据条件返回图表需要的数据用于显示
    @GetMapping("showChart/{type}/{begin}/{end}")
    public R showChart(@PathVariable String type,@PathVariable String begin,@PathVariable String end){
        //用map封装需要的数据
        Map<String,Object> map = dailyService.showChart(type,begin,end);
        return R.ok().data(map);
    }
}

